package org.idea.spring.framework.tx.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.idea.spring.framework.tx.config.druid.DruidDataSourceConfig;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;

import javax.annotation.Resource;

/**
 * @Author linhao
 * @Date created in 6:41 下午 2021/5/20
 */
@Configuration
public class JdbcConfig {

    @Resource
    private DruidDataSource druidDataSource;

    @Bean
    public JdbcTemplate jdbcTemplate(){
        System.out.println("初始化jdbctemplate");
        JdbcTemplate jdbcTemplate = new JdbcTemplate();
        jdbcTemplate.setDataSource(druidDataSource);
        System.out.println(druidDataSource);
        return jdbcTemplate;
    }
}
